using Com.LuisPedroFonseca.ProCamera2D;
using UnityEngine;
using UnityEngine.UI;

public class CameraEffectBeforeGame : MonoBehaviour
{
	public Camera cameraMain;

	public float sizeCamOut;

	public float sizeCamIn;

	private Vector3 posZoomOut;

	private Vector3 posZoomIn;

	private bool zoomOut;

	private bool zoomIn;

	public float speedZoom = 100f;

	public ProCamera2D procam;

	public Button btnZoomOut;

	public Button btnDone;

	private void Awake()
	{
		zoomOut = false;
		zoomIn = false;
		btnZoomOut.onClick.AddListener(delegate
		{
			StartZoomOut();
		});
		btnDone.onClick.AddListener(delegate
		{
			StartZoomIn();
		});
		btnDone.gameObject.SetActive(value: false);
	}

	private void Update()
	{
		if (zoomOut)
		{
			base.transform.position = Vector3.Lerp(base.transform.position, posZoomOut, Time.deltaTime * speedZoom);
			float orthographicSize = Mathf.Lerp(cameraMain.orthographicSize, sizeCamOut, Time.deltaTime * speedZoom);
			cameraMain.orthographicSize = orthographicSize;
			zoomOut = !checkZoomComplete(posZoomOut);
			if (!zoomOut)
			{
				EndZoomOut();
			}
		}
		if (zoomIn)
		{
			base.transform.position = Vector3.Lerp(base.transform.position, posZoomIn, Time.deltaTime * speedZoom);
			float orthographicSize2 = Mathf.Lerp(cameraMain.orthographicSize, sizeCamIn, Time.deltaTime * speedZoom);
			cameraMain.orthographicSize = orthographicSize2;
			zoomIn = !checkZoomComplete(posZoomIn);
			if (!zoomIn)
			{
				EndZoomIn();
			}
		}
	}

	public void EndZoomOut()
	{
		btnDone.gameObject.SetActive(value: true);
	}

	public void EndZoomIn()
	{
		//btnZoomOut.gameObject.SetActive(value: false);
		btnDone.gameObject.SetActive(value: false);
		GUIManager.Instance.panelUIGPL.SetActive(value: true);
		PlayerControlManager.Instance.ModeReivew(status: true);
        //if (!AdManager1.instance.ShieldAddress) AdManager.single.ShowNative();
    }

	public void StartZoomOut()
	{
		//AdManager.Instance.ShowInterstitial();
		GUIManager.Instance.panelUIGPL.SetActive(value: false);
		PlayerControlManager.Instance.ModeReivew(status: false);
		//btnZoomOut.gameObject.SetActive(value: false);
		sizeCamIn = cameraMain.orthographicSize;
		posZoomIn = base.transform.position;
		procam.enabled = false;
		zoomOut = true;
        //if (!AdManager1.instance.ShieldAddress) AdManager.single.ShowNative();
    }

	public void StartZoomIn()
	{
		btnDone.gameObject.SetActive(value: false);
		zoomOut = false;
		zoomIn = true;
	}

	public void setInfo(Vector3 posZoomOut, float size)
	{
		this.posZoomOut = new Vector3(posZoomOut.x, posZoomOut.y, base.transform.position.z);
		sizeCamOut = size;
	}

	public bool checkZoomComplete(Vector3 target)
	{
		if (Vector3.Distance(base.transform.position, target) <= 0.5f)
		{
			return true;
		}
		return false;
	}
}
